﻿using DeviceMaintainGIS.BLL.Device;
using DeviceMaintainGIS.Common;
using DeviceMaintainGIS.Model;
using DeviceMaintainGIS.Model.Replace;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Script.Serialization;

namespace DeviceMaintainGIS.Controllers
{
    /// <summary>
    /// 维修换新信息
    /// </summary>
    public class ReplaceController : ApiController
    {
        /// <summary>
        /// 获取维修信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ReturnListVM<ReplaceResponse> Get([FromUri]ReplaceSelectRequest request)
        {
            return new DeviceService().GetRemoteInfoList(request);
        }
        /// <summary>
        /// 维修换新编辑或添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        // POST: api/Replace
        public ReturnMessageVM Post([FromBody]ReplaceRequest request)
        {
            JavaScriptSerializer jsonSerialize = new JavaScriptSerializer();
            String strJson = jsonSerialize.Serialize(request);//输出结果：{"Id":1,"UserName":"张三","Time":"\/Date(1297950721668)\/"}
            string pars = string.Format("维修换新提交或保存请求：\r\n 时间 = {0};\r\n 参数 = {1};"
            , System.DateTime.Now
            , strJson);
            LogHelper.WriteLog(typeof(FilterConfig), pars);
            return new DeviceService().RemoteOperation(request);
        }

    }
}
